home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Viewers / aa_m68k_Intel_Only / ToyViewer1.2 / Source / ToyWinBMP.m < prev    next >
Encoding:
Text File  |  1995-11-12  |  1018 b   |  41 lines

  1. #import "ToyWinBMP.h"
  2. #import "bmp.h"
  3.  
  4. @implementation ToyWinBMP
  5.  
  6. - (int)drawToyWin:(const char *)fileName Type:(int)type Num:(int)num
  7. {
  8.     FILE *fp;
  9.     bmpHeader *bh = NULL;
  10.     commonInfo *cinf = NULL;
  11.     int bits = 8, err = 0;
  12.     unsigned char *map[5];
  13.  
  14.     if ((fp = fopen(fileName, "r")) == NULL)
  15.         return Err_OPEN;
  16.     if ((bh = loadBmpHeader(fp, &err)) == NULL) {
  17.         (void)fclose(fp);
  18.         return err;
  19.     }
  20.  
  21.     [self initLocateWindow:fileName Width:bh->x Height:bh->y Num:num];
  22.  
  23. /* Bitmap data of planes in 'map[]' is one block of memory area.
  24.    map[0] is beginning of the area, and map[1] = map[0] + (size of plane),
  25.    and so on. But, if the image is monochrome, map[1] is NULL.
  26.    The area of map[0] and (commonInfo *)cinf are kept in an object of
  27.    ToyView, and freed by it.
  28. */
  29.     err = bmpGetImage(fp, bh, &bits, map);
  30.     cinf = bmpInfo(bh, bits, (map[1] == NULL));
  31.     freeBmpHeader(bh);
  32.     (void)fclose(fp);
  33.     if (err) /* •ä„ö⁄˛⁄ë */
  34.         errAlert(fileName, err);
  35.     if ([self drawView:map info: cinf] == nil)
  36.         return -1;
  37.     return 0;
  38. }
  39.  
  40. @end
  41.